-
Couldn't load subscription status.
- Fork 20
Don't stop pools #1199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't stop pools #1199
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (3)
src/frequenz/sdk/timeseries/pv_pool/_pv_pool.py:181
- Removing this cleanup call might leave pending tasks or open channels. Consider verifying that _pool_ref_store's resources are managed appropriately elsewhere, and document the reasoning for this removal.
await self._pool_ref_store.stop()
src/frequenz/sdk/timeseries/ev_charger_pool/_ev_charger_pool.py:219
- Ensure that omitting the stop operation on _pool_ref_store doesn't lead to resource leaks. If resource cleanup is handled in another part of the code, an inline comment explaining this would improve clarity.
await self._pool_ref_store.stop()
src/frequenz/sdk/timeseries/battery_pool/_battery_pool.py:401
- Double-check that the removal of the stop call does not leave orphaned tasks or channels. Consider adding tests or documentation to confirm that resource management remains intact.
await self._pool_ref_store.stop()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow but the formulas are shared, too.
So we have the same problem if 2 actors uses the same formula (like BatteryPool.power()) and one of them stops it.
And the same for microgrid.producer().power - one actor stops it, it won't work for other actors.
So this PR won't fix the problem :/
Maybe quick fix would be to not share pools & formulas? (I don't know how much work it would be).
Or have counter (how many is active and how many stopped
| async def stop(self) -> None: | ||
| """Stop all tasks and channels owned by the EVChargerPool.""" | ||
| await self._pool_ref_store.stop() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add comment why this methods are empty?
It looks like bug now, because method description and definition does different thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
👋 reference counting 👋 |
When there are multiple pool instances controlling the same components and one of them stops, that would stop all the pools. This commit adds an emergency fix to prevent this bug, to buy some time to come up with a better solution. Signed-off-by: Sahas Subramanian <[email protected]>
Signed-off-by: Sahas Subramanian <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving because I guess if you are making a PR with such a hack, you really need it urgently, but I think the release notes are a bit misleading. You fixed a bug by introducing a new bug (pools are not stopped) 😆
This is not a problem. Users only want to close the resources that they have created. So when they make a We don't have the idiom of holding references to built-in formulas. When people create custom formulas, they can stop those; that's fine. Also, when formulas are closed by mistake, it's immediately noticeable. But when the battery pool is closed by mistake and we're only subscribing to SOC or capacity, for example, it's much more dangerous because we'll just assume the value hasn't changed.
Because there are so many metrics, that would quickly become a noticeable overhead. Additionally, the pools share access to the power manager, etc. I think we should just look for a proper solution, hopefully next week. |
When there are multiple pool instances controlling the same components and one of them stops, that would stop all the pools.
This PR adds an emergency fix to prevent this bug, to buy some time to come up with a better solution.